package com.example.music_project.tools;

import lombok.Data;

@Data
public class Result<T> {
    private Integer code; //状态码 200 表示成功 -1 表示失败，-2 表示未登录
    private String errorInfo; // 错误信息
    private T data; // 返回的数据

    public Result<T> success(T data) {
        Result<T> result = new Result<>();
        result.code = Constant.SUCCESS;
        result.data = data;
        return result;
    }
    public Result<T> success() {
        Result<T> result = new Result<>();
        result.code = Constant.SUCCESS;
        result.data = data;
        return result;
    }

    public Result<T> fail(String errorMage) {
        Result<T> result = new Result<>();
        result.code = Constant.FAIL_CODE;
        result.errorInfo = errorMage;
        return result;
    }

    public Result<T> UnLogin() {
        Result<T> result = new Result<>();
        result.code = Constant.NOT_LOGIN;
        result.errorInfo = "用户未登录";
        return result;
    }

}
